package cn.airia.as3wplib.service.impl
{
	
	
	import cn.airia.as3wplib.cfg.Configuration;
	import cn.airia.as3wplib.rpc.BaseServiceDelegate;
	import cn.airia.as3wplib.rpc.DelegateFactory;
	import cn.airia.as3wplib.service.IWordPressService;
	
	public class WordPressServiceImpl implements IWordPressService
	{
		private var xmlrpc_url:String = Configuration.getInstance().xmlrpcUrl;
		private var wpXmlrpc:BaseServiceDelegate;
		
		public function WordPressServiceImpl()
		{
			wpXmlrpc = DelegateFactory.getDelegate(DelegateFactory.TYPE_XMLRPC,xmlrpc_url);	
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getUsersBlogs()
		 */
		public function getUsersBlogs(username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(username,password);
			wpXmlrpc.invoke("wp.getUsersBlogs",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getTags()
		 */
		public function getTags(blog_id:int, username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password);
			wpXmlrpc.invoke("wp.getTags",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getCommentCount()
		 */
		public function getCommentCount(blog_id:int, username:String, password:String, post_id:int, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,post_id);
			wpXmlrpc.invoke("wp.getCommentCount",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getPostStatusList()
		 */ 
		public function getPostStatusList(blog_id:int, username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password);
			wpXmlrpc.invoke("wp.getPostStatusList",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getPageStatusList()
		 */
		public function getPageStatusList(blog_id:int, username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password);
			wpXmlrpc.invoke("wp.getPageStatusList",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getPageTemplates()
		 */
		public function getPageTemplates(blog_id:int, username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password);
			wpXmlrpc.invoke("wp.getPageTemplates",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getOptions()
		 */
		public function getOptions(blog_id:int, username:String, password:String, options:Array, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,options);
			wpXmlrpc.invoke("wp.getOptions",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#setOptions()
		 */
		public function setOptions(blog_id:int, username:String, password:String, options:Object, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,options);
			wpXmlrpc.invoke("wp.setOptions",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#deleteComment()
		 */
		public function deleteComment(blog_id:int, username:String, password:String, comment_id:int, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,comment_id);
			wpXmlrpc.invoke("wp.deleteComment",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#editComment()
		 */
		public function editComment(blog_id:int, username:String, password:String, comment_id:int, comment:Object, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,comment_id,comment);
			wpXmlrpc.invoke("wp.editComment",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#newComment()
		 */
		public function newComment(blog_id:int, username:String, password:String, post_id:int, comment:Object, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,post_id,comment);
			wpXmlrpc.invoke("wp.newComment",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getCommentStatusList()
		 */
		public function getCommentStatusList(blog_id:int, username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password);
			wpXmlrpc.invoke("wp.getCommentStatusList",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getPage()
		 */
		public function getPage(blog_id:int, page_id:int, username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(blog_id,page_id,username,password);
			wpXmlrpc.invoke("wp.getPage",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getPages()
		 */
		public function getPages(blog_id:int, username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password);
			wpXmlrpc.invoke("wp.getPages",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getPageList()
		 */
		public function getPageList(blog_id:int, username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password);
			wpXmlrpc.invoke("wp.getPageList",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#newPage()
		 */
		public function newPage(blog_id:int, username:String, password:String, page:Object,publish:Boolean,retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,page,publish);
			wpXmlrpc.invoke("wp.newPage",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#deletePage()
		 */
		public function deletePage(blog_id:int, username:String, password:String, page_id:int, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,page_id);
			wpXmlrpc.invoke("wp.deletePage",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#editPage()
		 */
		public function editPage(blog_id:int, page_id:int, username:String, password:String, content:Object, publish:Boolean, retFun:Function):void
		{
			var params:Array = new Array(blog_id,page_id,username,password,content,publish);
			wpXmlrpc.invoke("wp.editPage",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getAuthors()
		 */
		public function getAuthors(blog_id:int, username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password);
			wpXmlrpc.invoke("wp.getAuthors",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getCategories()
		 */
		public function getCategories(blog_id:int, username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password);
			wpXmlrpc.invoke("wp.getCategories",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#newCategory()
		 */
		public function newCategory(blog_id:int, username:String, password:String, category:Object, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,category);
			wpXmlrpc.invoke("wp.newCategory",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#deleteCategory()
		 */
		public function deleteCategory(blog_id:int, username:String, password:String, category_id:int, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,category_id);
			wpXmlrpc.invoke("wp.deleteCategory",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#suggestCategories()
		 */
		public function suggestCategories(blog_id:int, username:String, password:String, category:String, max_results:int, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,category,max_results);
			wpXmlrpc.invoke("wp.suggestCategories",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#uploadFile()
		 */
		public function uploadFile(blog_id:int, username:String, password:String, data:Object, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,data);
			wpXmlrpc.invoke("wp.uploadFile",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getComment()
		 */
		public function getComment(blog_id:int, username:String, password:String, comment_id:int, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,comment_id);
			wpXmlrpc.invoke("wp.getComment",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IWordPressService#getComments()
		 */
		public function getComments(blog_id:int, username:String, password:String, struct:Object, retFun:Function):void
		{
			var params:Array = new Array(blog_id,username,password,struct);
			wpXmlrpc.invoke("wp.getComments",params,retFun);
		}
	}
}